package com.ibl.rover.lite.client.Sync.Parser;

import com.mobile.sync.client.Sync.IHandler;
import com.mobile.sync.client.Sync.ResponseInfo;
import com.mobile.sync.client.impl.AbstractBean;
import com.mobile.sync.client.impl.ResponseBean;

public class ResponseHandler implements IHandler {

	private String name;

	String getName() {
		return this.name;
	}

	public ResponseHandler(String name) {
		this.name = name;
	}

	@Override
	public void handlerResponse(AbstractBean responseBean) {
		try {
			if (responseBean.getDataChunk() != null) {
				ResponseBean httpResponse = (ResponseBean) responseBean;
				ResponseInfoParser parser = new ResponseInfoParser();

				// Utility utility = new Utility();
				// byte[] base64Encded =
				// base64decode(responseMsg.getBodyChunk());
				// byte[] deCompressedXml =
				// utility.decompressData(base64Encded);
				// responseMsg.setBodyChunk(null);
				// base64Encded = null;
				// responseMsg.setBodyChunk(deCompressedXml);

 				parser.parse(responseBean.getDataChunk());

				ResponseInfo responseInfo = parser.getResponseInfo();
				httpResponse.setMessageCode(Integer.parseInt(responseInfo
						.getServerCode()));
				httpResponse.setMessage(responseInfo.getServerMessage());
			}
		} catch (Exception e) {

		}
	}

}
